package com.apache.funds.service.plugins;

import java.util.List;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.funds.entity.SvmCaptionBalance;
import com.apache.funds.manager.SvmCaptionBalanceManager;

/**
 * 本类主要涉及业务逻辑<br>
 * 1.内部使用（操作期初表，初始化余额）
 */
public class FundsCaptionBalancePlugin implements PluginConnector {

	private SvmCaptionBalanceManager svmCaptionBalanceManager;
	protected final String entityName = "com.apache.common.entity.SvmVoucherDetail";

	@Override
	public Object execute(ParamsVo vo) throws Exception {
		if (vo.getParams("fg").equals("query")) {
			List<SvmCaptionBalance> list = svmCaptionBalanceManager.getList(vo);
			if (list != null) {
				if (list.size() > 0) {
					return list.get(0);
				} else {
					return null;
				}
			} else {
				return null;
			}
		} else {
			return svmCaptionBalanceManager.saveInfo(vo);
		}
	}

	public void setSvmCaptionBalanceManager(SvmCaptionBalanceManager svmCaptionBalanceManager) {
		this.svmCaptionBalanceManager = svmCaptionBalanceManager;
	}
}
